# Create your views here.

from django.http import HttpResponse
import datetime
from django.template.loader import get_template
from django.template import Context
from django.views.decorators.csrf import csrf_exempt
from Notes4me.notes.models import Note

def current_datetime(request):
    now = datetime.datetime.now()
    t = get_template('notes_list.html')
    html = t.render(Context({'current_date' : now}))
    return HttpResponse(html)

@csrf_exempt
def updateNote(request):
    if request.method == 'GET':
        getUpdateNote(request)
    elif request.method == 'POST':
        postUpdateNote(request)
    return HttpResponse(content='ok', status=200)

def showAllNotes(request):
    return 0

def postUpdateNote(request):
    #postParams = request.POST
    #print postParams['notes']
    postUpdateNotesparams = request.POST
    print postUpdateNotesparams.__getitem__('notes')
    print 'Enter update not11e method'
    noteContent = postUpdateNotesparams.__getitem__('notes')
    notrUrl = postUpdateNotesparams.__getitem__('noteUrl')
    note = Note(content=noteContent,noteType=1, url=notrUrl, title='test')
    note.save()
    

def getUpdateNote(request):
    getParams = request.GET
    print 'Test get params:' + getParams.__getitem__('notes')
